package com.fumin.util;

import com.google.common.base.Splitter;

import java.util.List;
import java.util.stream.Collectors;

public class StringUtil {

    //1,2,3 ->[1,2,3];
    // 1,2,3,->[1,2,3];
    // 1,2,3,,->[1,2,3]
    public static List<Integer> splitToListInt(String str) {
        List<String> strList = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(str);//设置分隔符,然后去除空格和空白字符串,再split数组
        return strList.stream().map(strItem -> Integer.parseInt(strItem)).collect(Collectors.toList());
    }
}
